
import 'BaseBean.dart';

class BaseListBean<T extends BaseJsonBean> extends BaseBean{

  BaseListDataBean<T>? data;

  BaseListBean({code,message,this.data}):super(code: code, message: message);

  BaseListBean.fromJson(Map<String, dynamic> json,Function(Map<String, dynamic>) itemCreate):super.fromJson(json){
      data=BaseListDataBean.fromJson(json["data"],itemCreate);
  }

  Map<String, dynamic> toJson() {
    var json = super.toJson();
    json['data'] = this.data?.toJson();
    return json;
  }
}

class BaseListDataBean<T extends BaseJsonBean>{
  int? pageNum;
  int? pageSize;
  int? totalPage;
  int? total;
  List<T>? result;

  BaseListDataBean({this.pageNum, this.pageSize, this.totalPage, this.total, this.result});

  BaseListDataBean.fromJson(Map<String, dynamic> json,Function(Map<String, dynamic>) itemCreate) {
    pageNum = json['pageNum'];
    pageSize = json['pageSize'];
    totalPage = json['totalPage'];
    total = json['total'];
    if (json['result'] != null) {
      result = [];
      json['result'].forEach((v) {
          result?.add(itemCreate(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['pageNum'] = this.pageNum;
    data['pageSize'] = this.pageSize;
    data['totalPage'] = this.totalPage;
    data['total'] = this.total;
    if (this.result != null) {
      data['result'] = this.result?.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
